﻿@model thailandProject.Models.PagedList<thailandProject.Models.CLIENT>

@{
    ViewBag.Title = "Properties";
    int i = 0;
}

<div id="Wrapper2">
    <div id="content_header">
        <div id="headerimage">
        </div>
        <div id="theheader">@ViewBag.Header</div>
    </div>
    <!-- Left Column begins here -->
    <aside id="sidebar-wrapper">
        <nav class="sidebar">
           <div id="availableProperties">    
           <h1>Select Client</h1>
            <div id = "searchcontainer">
                Search for a client and click "Reserve" to reserve the rooms that were selected on the previous page.
                @using (Html.BeginForm("SelectClient2", "Property"))
                {
                    <input style="color:#999999;" id="searchclient" data-autocomplete="@Url.Action("QuickSearch", "clients")" name="clientName" type="text" />
                    <input type="image" alt="search" src="../../images/searchicon.png" />
                }
            </div>
                <br />
                @if (Model != null)
                {
                    <table cellspacing="0" cellpadding="5" id="searchclienttable">
                        <tr id="searchclienttoprow">
                            <th class="searchclientcols20">
                                @Html.ActionLink("First", "SelectClient2", new
                           {
                               pageNumber = ViewBag.PageNumber,
                               sortType = "clientFirstName"
                           })
                                @Html.ActionLink("Last", "SelectClient2", new
                           {
                               pageNumber = ViewBag.PageNumber,
                               sortType = "clientLastName"
                           })
                            </th>
                            <th class="searchclientcols20">
                                @Html.ActionLink("City", "SelectClient2", new
                           {
                               pageNumber = ViewBag.PageNumber,
                               sortType = "clientCity"
                           })
                            </th>
                            <th class="searchclientcols35">
                                @Html.ActionLink("Email", "SelectClient2", new
                           {
                               pageNumber = ViewBag.PageNumber,
                               sortType = "clientEmail"
                           })
                            </th>
                            <th style="width:5%;"><!-- View Column -->
                            </th>
                        </tr>
                        <tr>
                            <th colspan="5">
                                @Html.ActionLink("Add New Client...", "AddClient")
                            </th>
                        </tr>
                        
                    @foreach (var client in Model)
                    {
                        //Ensure that Model isn't null. It will be null on the first load
                        // if odd row, keep same row color
                        if (thailandProject.Models.UtilMethods.isOdd(i))
                        {
                         <tr style="background:url('/images/transblack1.png') repeat scroll 0 0 transparent;" class="searchclientrow">
                        
                            <td style="border-bottom:1px dotted #cccccc; font-weight:bold;">
                                @Html.DisplayFor(modelItem => client.clientFirstName)
                                @Html.DisplayFor(modelItem => client.clientLastName)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @Html.DisplayFor(modelItem => client.clientCity)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @Html.Raw(thailandProject.Models.UtilMethods.stringWithBreak(client.clientEmail.ToString()))
                            </td>
                            <td style="text-align:right; border-bottom:1px dotted #cccccc;"> 
                            @{
                                string reserve_link = "SelectClientReserve?clientId=" + client.clientID;
                                <a href="@reserve_link"><img src="../../images/reserve_small_long.png" alt="reserve" /></a>
                            }
                            </td>
                        </tr>
                        }
                        // if not odd row, then show a slight color change for better view
                        else
                        {
                         <tr class="searchclientrow">
                        
                            <td style="border-bottom:1px dotted #cccccc; font-weight:bold;">
                                @Html.DisplayFor(modelItem => client.clientFirstName)
                                @Html.DisplayFor(modelItem => client.clientLastName)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @Html.DisplayFor(modelItem => client.clientPassportNum)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @Html.Raw(thailandProject.Models.UtilMethods.stringWithBreak(client.clientEmail.ToString()))
                            </td>
                            <td style="text-align:right; border-bottom:1px dotted #cccccc;">
                            @{
                                string reserve_link = "SelectClientReserve?clientId=" + client.clientID;
                                <a href="@reserve_link"><img src="../../images/reserve_small_long.png" alt="reserve" /></a>
                            }
                            </td>
                        </tr>   
                        }
                        i++;
                    }
                        <!-- Prev Page -- Next Page -->
                        <tr>
                            <td style="border-bottom:1px dotted #cccccc" colspan="2">
                                @if (Model.hasPreviousPage)
                                {
                                    @Html.ActionLink("< Prev", "SelectClient2", new
                               {
                                   pageNumber = ViewBag.PageNumber - 1,
                                   sortType = ViewBag.SortType
                               })
                                }
                                else
                                {
                                    @Html.Raw("< Prev");
                                }
                            </td>
                            <td style="border-bottom:1px dotted #cccccc; text-align:right" colspan="3">
                                @if (Model.hasNextPage)
                                {
                                    @Html.ActionLink("Next >", "SelectClient2", new
                               {
                                   pageNumber = ViewBag.PageNumber + 1,
                                   sortType = ViewBag.SortType
                               })
                                }
                                else
                                {
                                    @Html.Raw("Next >");
                                }
                            </td>
                        </tr>
                        </table>
                }
               <br />
           </div>
        </nav>
        
        <!-- Left column ends here -->
    </aside>
    <!-- Right column begins here -->
    <article id="contents">
       
    </article>
    <!-- Right column ends here -->
</div>
<!-- Div wrapper2 ends here -->


<script type = "text/javascript">
    $(function () {
        $(".datepicker").datepicker();
    });

    $(document).ready(function () {

        $(":input[data-autocomplete]").each(function () {
            $(this).autocomplete({ source: $(this).attr("data-autocomplete") });
        });

    })
</script>